package com.th.therp.controller;

import com.th.therp.pojo.result.Result;
import com.th.therp.pojo.vo.DashboardMonthVo;
import com.th.therp.pojo.vo.DashboardOrderVo;
import com.th.therp.service.DashboardService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 图标数据请求控制器
 */
@Log4j2
@RestController
@RequestMapping("/dashboard")
public class DashboardController {

    @Autowired
    private DashboardService dashboardService;

    @GetMapping("/order")
    @ResponseBody
    public Result<DashboardOrderVo> order() {
        log.info("采销订单仪表");
        DashboardOrderVo dashboardOrderVo = dashboardService.order();
        return Result.success(dashboardOrderVo);
    }

    @GetMapping("/month")
    @ResponseBody
    public Result<List<DashboardMonthVo>> month() {
        log.info("月度销售仪表");
        List<DashboardMonthVo> dashboardMonthVoList = dashboardService.month();
        return Result.success(dashboardMonthVoList);
    }
}
